package com.jyc.service;

import com.jyc.entity.ck.Shebeiguihai;
import com.jyc.mapper.ck.ShebeiguihaiMapper;
import com.jyc.mapper.ck.UserInfoMapper;
import com.jyc.vo.ck.ShebeiguihaiVO;
import com.jyc.vo.zuche.ZucheChartVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

@Service
@Transactional
public class CKService {
    @Autowired(required = false)
    private ShebeiguihaiMapper shebeiguihaiMapper;
    @Autowired(required = false)
    private UserInfoMapper userInfoMapper;

    public List<Shebeiguihai> getItemList() {
        return shebeiguihaiMapper.selectByExample(null);
    }

    public List<ShebeiguihaiVO> showPie() {
        return shebeiguihaiMapper.showPie();
    }

    public List<ShebeiguihaiVO> showPillar() {
        return shebeiguihaiMapper.showPillar();
    }

    public List<ShebeiguihaiVO> showLine() {
        return shebeiguihaiMapper.showLine();
    }

    public Set<List> show3D() {
        Set<List> dataSet = new LinkedHashSet<>();
        List<String> times = shebeiguihaiMapper.selectTime();
        List<String> fenleis = shebeiguihaiMapper.selectFeilei();
        for (String time : times) {
            if (dataSet.size() == 0) {
                List first = new ArrayList();
                first.add("租用日期");
                first.add("型号");
                first.add("数量");
                dataSet.add(first);
            }
            List<ShebeiguihaiVO> shebeiguihaiVOS = shebeiguihaiMapper.showOneInfoByTime(time);
            for (ShebeiguihaiVO shebeiguihaiVO : shebeiguihaiVOS) {
                List tempList= new ArrayList();
                tempList.add(time);
                tempList.add(shebeiguihaiVO.getFenlei());
                tempList.add(shebeiguihaiVO.getTotalshuliang());
                dataSet.add(tempList);
            }
        }
        /*for (String fenlei : fenleis) {
            ShebeiguihaiVO shebeiguihaiVO = shebeiguihaiMapper.showOneInfoByFenlei(fenlei);
            if (dataSet.size() == 0) {
                List first = new ArrayList();
                first.add("租用日期");
                first.add("型号");
                first.add("数量");
                dataSet.add(first);
            }
            List tempList= new ArrayList();
            tempList.add(shebeiguihaiVO.getTime());
            tempList.add(fenlei);
            tempList.add(shebeiguihaiVO.getTotalshuliang());
            dataSet.add(tempList);
        }*/
        System.out.println(dataSet.toString());
        System.out.println(dataSet.size());
        return dataSet;
    }
}
